import X2js from 'x2js'
import Vkbeautify from 'vkbeautify'

export function format_json_xml(jsonObject, type) {
  const x2js = new X2js()
  if (type.toLowerCase().indexOf('json') > -1) {
    return JSON.stringify(jsonObject, null, 4)
  } else if (type.toLowerCase().indexOf('xml') > -1) {
    return Vkbeautify.xml(x2js.js2xml(jsonObject))
  }
}
